<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="pagebar" uri="http://neusoft.edu.cn/common/"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() 
	                   + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>高校师生在线交流平台</title>
	<!-- 引入css样式文件 -->
	<!-- Bootstrap Core CSS -->
	<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
	<!-- MetisMenu CSS -->
	<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />
	<!-- DataTables CSS -->
	<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />
	<!-- Custom CSS -->
	<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />
	<!-- Custom Fonts -->
	<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
  <!-- 导航栏部分 -->
  <nav class="navbar navbar-default navbar-static-top" role="navigation"
		 style="margin-bottom: 0">
	<div class="navbar-header">
		<a class="navbar-brand" href="<%=basePath%>bank/list.action">欢迎进入高校师生在线交流平台</a>
	</div>
	<!-- 导航栏右侧图标部分 -->
	<ul class="nav navbar-top-links navbar-right">
	    <!-- 邮件通知 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
				<i class="fa fa-envelope fa-fw"></i>
				<i class="fa fa-caret-down"></i>
			</a>
			<ul class="dropdown-menu dropdown-messages">
				<li>
				    <a href="#">
						<div>
							<strong>张经理</strong> <span class="pull-right text-muted">
								<em>昨天</em>
							</span>
						</div>
						<div>今天晚上开会，讨论一下下个月工作的事...</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a class="text-center" href="#">
				        <strong>查看全部消息</strong>
						<i class="fa fa-angle-right"></i>
				    </a>
				</li>
			</ul>
		</li>
		<!-- 邮件通知 end -->
		<!-- 任务通知 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
			    <i class="fa fa-tasks fa-fw"></i>
				<i class="fa fa-caret-down"></i>
			</a>
			<ul class="dropdown-menu dropdown-tasks">
				<li>
				    <a href="#">
						<div>
							<p>
								<strong>任务 1</strong> 
								<span class="pull-right text-muted">完成40%</span>
							</p>
							<div class="progress progress-striped active">
								<div class="progress-bar progress-bar-success"
									role="progressbar" aria-valuenow="40" aria-valuemin="0"
									aria-valuemax="100" style="width: 40%">
									<span class="sr-only">完成40%</span>
								</div>
							</div>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							<p>
								<strong>任务 2</strong> 
								<span class="pull-right text-muted">完成20%</span>
							</p>
							<div class="progress progress-striped active">
								<div class="progress-bar progress-bar-info" role="progressbar"
									aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"
									style="width: 20%">
									<span class="sr-only">完成20%</span>
								</div>
							</div>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a class="text-center" href="#"> 
				        <strong>查看所有任务</strong>
						<i class="fa fa-angle-right"></i>
				    </a>
				</li>
			</ul> 
		</li>
		<!-- 任务通知 end -->
		<!-- 消息通知 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
				<i class="fa fa-bell fa-fw"></i>
				<i class="fa fa-caret-down"></i>
			</a>
			<ul class="dropdown-menu dropdown-alerts">
				<li>
				    <a href="#">
						<div>
							<i class="fa fa-comment fa-fw"></i> 新回复 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							<i class="fa fa-envelope fa-fw"></i> 新消息 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							<i class="fa fa-tasks fa-fw"></i> 新任务 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a href="#">
						<div>
							<i class="fa fa-upload fa-fw"></i> 服务器重启 
							<span class="pull-right text-muted small">4分钟之前</span>
						</div>
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a class="text-center" href="#"> 
				        <strong>查看所有提醒</strong>
						<i class="fa fa-angle-right"></i>
				    </a>
				</li>
			</ul> 
		</li>
		<!-- 消息通知 end -->
		<!-- 用户信息和系统设置 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
				<i class="fa fa-user fa-fw"></i>
				<i class="fa fa-caret-down"></i>
			</a>
			<ul class="dropdown-menu dropdown-user">
				<li><a href="#"><i class="fa fa-user fa-fw"></i>
				               用户：${USER_SESSION.userName}
				    </a>
				</li>
				<li><a href="#"><i class="fa fa-gear fa-fw"></i> 系统设置</a></li>
				<li class="divider"></li>
				<li>
					<a href="${pageContext.request.contextPath }/logout.action">
					<i class="fa fa-sign-out fa-fw"></i>退出登录
					</a>
				</li>
			</ul> 
		</li>
		<!-- 用户信息和系统设置结束 -->
	</ul>
	<!-- 左侧显示列表部分 start-->
	<div class="navbar-default sidebar" role="navigation">
		<div class="sidebar-nav navbar-collapse">
			<ul class="nav" id="side-menu">
				<li class="sidebar-search">
					<div class="input-group custom-search-form">
						<input type="text" class="form-control" placeholder="查询内容...">
						<span class="input-group-btn">
							<button class="btn btn-default" type="button">
								<i class="fa fa-search" style="padding: 3px 0 3px 0;"></i>
							</button>
						</span>
					</div> 
				</li>
				<li>
				      <a href="${pageContext.request.contextPath }/question/list.action">
				        <i class="fa fa-dashboard fa-fw" ></i> 问题管理
				      </a>
				</li>				
				<li>
				    <a href="${pageContext.request.contextPath }/student/list.action">
				      <i class="fa fa-edit fa-fw"></i> 学生管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/class/list.action">
				      <i class="fa fa-tasks fa-fw"></i> 班级管理
				    </a>
				</li>
				
									
			</ul>
		</div>
	</div>
	<!-- 左侧显示列表部分 end--> 
</nav>

	<div id="page-wrapper">	
		<a href="#" class="btn btn-primary" role="button" data-toggle="modal" data-target="#newSchoolDialog">新建</a>
		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-heading">问题信息列表</div>
					<!-- /.panel-heading -->
					<table class="table table-bordered table-striped">
						<thead>
							<tr>
								<th>问题编号</th>
								<th>问题描述</th>
								<th>是否置顶</th>
								<th>难度</th>
								<th>是否解决</th>
								<th>课程种类</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${page.rows}" var="row">
								<tr>
									<td>${row.q_id}</td>
									<td>${row.descrip}</td>
									<td>${row.is_top}</td>
									<td>${row.difficult}</td>
									<td>${row.is_solve}</td>
									<td>${row.kind}</td>
									<td>
										<a href="#" class="btn btn-primary btn-xs" role="button" data-toggle="modal" data-target="#schoolEditDialog" onclick= "editQuestion(${row.q_id})">修改</a>
										<a href="#" class="btn btn-danger btn-xs" onclick="deleteQuestion(${row.q_id})">删除</a>
									</td>
								</tr>
							</c:forEach>
							
						</tbody>
					</table>
					<div class="col-md-12 text-right">
						<pagebar:page url="${pageContext.request.contextPath }/question/list.action" />
					</div>
					<!-- /.panel-body -->
				</div>
				<!-- /.panel -->
			</div>
			<!-- /.col-lg-12 -->
		</div>
	</div>
	<!-- 商品列表查询部分  end-->
</div>

<!-- 创建用户模态框 -->
<div class="modal fade" id="newSchoolDialog" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">问题信息</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" id="new_school_form">
				
					<div class="form-group">
						<label for="new_descrip" class="col-sm-2 control-label">问题描述 </label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_descrip" placeholder="问题描述" name="descrip" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_is_top" class="col-sm-2 control-label">是否置顶</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_is_top" placeholder="是否置顶" name="is_top" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_difficult" class="col-sm-2 control-label">难度 </label>
						<div class="col-sm-10">
							<select	class="form-control" id="new_difficult" name="difficult">
								    <option value="">--请选择--</option>
									<option value="简单">简单</option>
									<option value="一般">一般</option>
									<option value="困难">困难</option>		
							</select>
						</div>
					</div>
					<div class="form-group">
						<label for="new_is_solve" class="col-sm-2 control-label">是否解决 </label>
						<div class="col-sm-10">
							<select	class="form-control" id="new_is_solve" name="is_solve">
								    <option value="">--请选择--</option>
									<option value="是">是</option>
									<option value="否">否</option>	
							</select>
						</div>
					</div>
					<div class="form-group">
						<label for="new_kind" class="col-sm-2 control-label">问题科目 </label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_kind" placeholder="问题科目" name="kind" />
						</div>
					</div>
					
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" onclick="createQuestion()">添加</button>
			</div>
		</div>
	</div>
</div>

<!-- 修改用户模态框 -->

<div class="modal fade" id="schoolEditDialog" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">修改学校信息</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" id="edit_school_form">
                   <input type="hidden" id="qid" name="q_id"/>

					<div class="form-group">
						<label for="edit_descrip" class="col-sm-2 control-label">
						    问题描述
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_descrip" placeholder=" 问题描述" name="descrip"/>
						</div>
					</div>
					<div class="form-group">
						<label for="edit_is_top" class="col-sm-2 control-label">是否置顶</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_is_top" placeholder="是否置顶" name="is_top" />
						</div>
					</div>
					<div class="form-group">
						<label for="edit_difficult" class="col-sm-2 control-label">难度</label>
						<div class="col-sm-10">
							<select	class="form-control" id="edit_difficult" name="difficult">
								    <option value="">--请选择--</option>
									<option value="简单">简单</option>
									<option value="一般">一般</option>
									<option value="困难">困难</option>		
							</select>
						</div>
					</div>
					<div class="form-group">
						<label for="edit_is_solve" class="col-sm-2 control-label">是否解决</label>
						<div class="col-sm-10">
						<select	class="form-control" id="edit_is_solve" name="is_solve">
								    <option value="">--请选择--</option>
									<option value="是">是</option>
									<option value="否">否</option>	
							</select>
							
						</div>
					</div>
					<div class="form-group">
						<label for="edit_kind" class="col-sm-2 control-label">种类</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_kind" placeholder="种类" name="kind" />
						</div>
					</div>
				</form>
			</div>
		    <div class="modal-footer">
				    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				    <button type="button" class="btn btn-primary" onclick="updateQuestion()">修改问题信息</button>
			</div>
			</div>
			
		</div>
</div>

<!-- 编写js文件 -->
<script type="text/javascript">
//清空创建时的数据
function clear() {
    $("#new_descrip").val("");
    $("#new_is_top").val("");
    $("#new_difficult").val("");
    $("#new_is_solve").val("");
    $("#new_kind").val("");
}

//新建用户
function createQuestion() {

    $.post("${pageContext.request.contextPath}/question/createQuestion.action",
		
    $("#new_school_form").serialize(),function(data){
           if(data =="OK"){
              alert("用户创建成功！");
              window.location.reload();
           }else{
              alert("用户创建失败！");
              window.location.reload();
           }
       
          });

   }

//通过id获取修改的用户信息
function editQuestion(q_id) {
	$.post("${pageContext.request.contextPath}/question/getQuestionById.action",{"qid":q_id},function(data){
		 $("#qid").val(data.q_id);
         $("#edit_descrip").val(data.descrip);
         $("#edit_is_top").val(data.is_top);
         $("#edit_difficult").val(data.difficult);
         $("#edit_is_solve").val(data.is_solve);
         $("#edit_kind").val(data.kind);

	});
}
// 执行修改用户信息操作
function updateQuestion() {
	
	$.post("${pageContext.request.contextPath}/question/updateQuestion.action",$("#edit_school_form").serialize(),function(data){
		if(data =="OK"){
			alert("问题信息更新成功！");
			window.location.reload();
		}else{
			alert("问题信息更新失败！");
			window.location.reload();
		}
	});
}


//删除用户
function deleteQuestion(q_id) {
    if(confirm('确实要删除该用户吗?')) {
$.post("${pageContext.request.contextPath}/question/deleteQuestion.action",{"qid":q_id},
function(data){
            if(data =="OK"){
                alert("用户删除成功！");
                window.location.reload();
            }else{
                alert("删除用户失败！");
                window.location.reload();
            }
        });
    }
}
</script>


<!-- 引入js文件 -->
<!-- jQuery -->
<script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="<%=basePath%>js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="<%=basePath%>js/sb-admin-2.js"></script>

</body>
</html>